

function codeToUpperCase(event){
  var e = window.event || event;   
  var target = e.srcElement || e.target;   
  var code =(e.keyCode || e.which);
   var loc=getLocation(target);
  if (code >= 65 && code <=90){
   	target.value= 	target.value.toUpperCase();
  }
  setCaret(target,loc);

  return false;  
}


function getChar(k) {  
  if(k >= 48 && k <= 57) {   
    return String.fromCharCode(k);   
  }   
  if(k >= 96 && k <= 105) {   
    return String.fromCharCode(k - 48);   
  }
  return String.fromCharCode(k);
} 


 function getLocation(obj){
	   obj.focus();
        var range = document.selection.createRange();
        range.moveStart("textedit",-1);
        return range.text.length;
  }



function setCaret(target,pos)
{
     var textbox =target;
     var r = textbox.createTextRange(); 
     r.collapse(true); 
     r.moveStart("character",pos); 
     r.select();
}
